package org.zn.note.spring.domain;

import lombok.AccessLevel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Id;

@Data
/*
@RequiredArgsConstructor 编译后如下：
public Ingredient(final String id, final String name, final Ingredient.Type type) { this.id = id; this.name = name; this.type = type;}
 */
@RequiredArgsConstructor
@Entity // jpa 注解
/*
jpa 需要无参构造器，但我们又不想直接使用，就AccessLevel.PRIVATE；但是有属性还是final的，就force=true，这样final的都是null
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true) 编译后如下：
private Ingredient() { this.id = null; this.name = null; this.type = null; }
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
public class Ingredient {
    @Id // jpa 注解
    private final String id;
    private final String name;
    private final Type type;

    public enum Type { // 跟接口一样，默认static的
        WRAP, PROTEIN, VEGGIES, CHEESE, SAUCE
    }
}
